package two_shang.otherTest.LuanQiBaZao;

import java.util.Objects;

public enum enumTest {

    //这些常量一般都是大写
    NORMAL(1, "s"),
    LXJ(2, "李学健"),
    LXZ(3, "李学智");

    enumTest(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }


    public String getName() {
        return name;
    }

    private int id;
    private String name;

    public static enumTest getInstance(int a) {
        enumTest thisEnum = null;
        enumTest[] values = enumTest.values();
        for (enumTest test : values) {
            if (Objects.equals(test.getId(), a)) {
                thisEnum = test;
            }
        }
        return thisEnum;
    }


    public static void main(String[] args) {
        System.out.println(enumTest.valueOf("LXJ").getId());
        System.out.println(enumTest.getInstance(2));
        System.out.println(enumTest.getInstance(1).ordinal());
        System.out.println(enumTest.getInstance(3).ordinal());
    }

}
